<?php
include $this->Render('header.php');
?>
<link rel="stylesheet" type="text/css" href="<?php echo BASE_STYLE;?>/css/admin.css" />
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/dyhl.linkpage.js"></script>
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/common.js"></script>
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/uploadifive/jquery.uploadifive.js"></script>
<style type="text/css">
    body {min-width:300px !important; overflow:scroll !important; overflow-x:hidden !important;}
    .order-item-box {
        width:100%;
        height:auto;
        overflow:hidden;
        padding-bottom:15px;
        margin-bottom:15px;
    }
</style>
<style type="text/css">
    .table_style{width: 100%;height: auto;}
    .table_style tr td{text-align: center;height: 30px;line-height: 30px;}
</style>
<style type="text/css">
    .uploadifive-button {width:84px;height:84px !important;line-height:normal;margin-top:-84px;background:none !important;}
    .file-upload-completed,.uploadifive-queue-item {position:absolute;width:84px;bottom:0;}
    .uploadifive-queue-item .close {background: url('<?php echo BASE_STYLE;?>/uploadifive/uploadifive-cancel.png') 0 0 no-repeat;display: block;float: right;height: 16px;text-indent: -9999px;width: 16px;}
    .uploadifive-queue-item .progress {height: 3px;margin-top: 5px;width: 100%;}
    .uploadifive-queue-item .progress-bar {background-color: #0072BC;height: 3px;width: 0;}
    .uploadifive-queue-item .filename {display:none;}
    input[type="text"],select {background:none;}
    .order-mianqian-load { padding:15px 10px;}
</style>
<div class="tongrong-box" style="width:680px;">
    <form class="order-item-box J-ajaxForm" action="/order/trolist/option/videosave/" method="post" autocomplete="off">
        <div class="tongrong-box-main">
            <table width="70%" cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <td width="20%" height="50">视频所属人:</td>
                <td>
                    <select name="owner" id="owner">
                        <option value="">请选择视频所属人</option>
                        <option value="<?php echo $this->message['vip_name'];?>"><?php echo $this->message['vip_name'];?></option>
                    <?php if(isset($this->message['spouse_name']))
                    {
                        echo '<option value="';
                        echo $this->message['spouse_name'];
                        echo '">';
                        echo  $this->message['spouse_name'];
                        echo  '</option>';
                    } ?>
                    <?php if(isset($this->message['guarantor_name']))
                    {
                        for($a = 0;$a<count($this->message['guarantor_name']);$a++){
                            echo '<option value="';
                            echo $this->message['guarantor_name'][$a];
                            echo '">';
                            echo  $this->message['guarantor_name'][$a];
                            echo  '</option>';
                        }
                    } ?>
                    </select>
                </td>
                </tr>
            </table>
        </div>
            <dl class="mianqianxinxi-box">
                <dt>视频类</dt>
                <dd class="mianqianxinxi-pic-list J-box-order-video">
                    <?php if(!empty($this->order['attachment']['oa_video'])) foreach($this->order['attachment']['oa_video'] as $k=>$v){?>
                    <div style="position:relative;display:inline-block; float:left;margin-right:10px;">
                        <em class="ico-close J-ico-close"></em>
                        <a href="javascript:;" class="J-video-obj" data-url="<?php echo $this->order['attachment']['oa_video_url'][$k];?>" style="position:relative; display:inline-block; width:80px;height:80px;margin-right:10px;">
                            <img src="<?php echo BASE_STYLE;?>/images/member/default_sildeshow.gif" width="80" height="80" />
                            <input type="hidden" value="<?php echo $v;?>" name="oa_video[]" />
                        </a>
                    </div>
                    <?php
                    }
                    ?>
                </dd>
                <dd>
                    <div class="file-upload-box J-file-upload-box fn-left mr10">
                        <div class="file-upload-completed" id="J_order_video"></div>
                        <img src="<?php echo BASE_STYLE;?>/images/btn_file_upload.png" />
                        <input type="file" id="upload_order_video" name="upload-pic" size="30" hidefocus="true" multiple='false' />
                        <p>111</p>
                    </div>
                </dd>
            </dl> 
            <table>
            <tr>
                <?php if(!empty($this->order['attachment']['oa_video'])) foreach($this->order['attachment']['oa_video'] as $k=>$v){?>
                <td style="text-align:center;vertical-align:middle;width:84px;height:14px !important;">1111</td>
                <td style=";width:14px;height:14px !important;"></td>
                <?php
                }
                ?>
            </table>  
        <div style=" height:40px; overflow:hidden; margin-top:20px;">
            <input type="hidden" name="oid" value="<?php echo $this->order['base']['o_id'];?>" />
            <input type="hidden" name="video_owner" id="video_owner" value="" />
            <input id="video_submit" type="submit" class="btn-submit-blue fn-left mr10" value="保存" />
            <a href="" class="a-btn-close J-a-btn-close fn-left">关闭</a>
        </div>
</form>
</div>
<script type="text/javascript">
    <?php $timestamp = time();?>
    function render_upload() {
        var key ='order_video';
        var url="/order/upfile/option/video/";
        var fileTypeTxt = 'video/*';

        $('#upload_'+key).uploadifive({
            'auto': true,
            'width': 84,
            'buttonText': '',
            'removeTimeout':1,
            'fileObjName':'upload-pic',
            'formData': {
                'timestamp': '<?php echo $timestamp;?>',
                'tb':key,
                'filebox':'upload-pic',
                'token': '<?php echo md5('unique_salt' . $timestamp);?>',
                'owner_name' :owner_name
            },
            'number':key,
            'queueClass':'.J-box-order-video',
            'uploadScript': url,
            'removeCompleted' : true,
            'onSelect' : function(q, opt){
                //$('#'+opt.formData.key + opt.number).find('a').remove();
            },
            'onUploadComplete': function (file, data, opt) {
            var obj = $.parseJSON(data);
            if (data == 0) {
                alert('您上传的文件不是允许的图片文件！');
                return;
            };
            if(obj['success']){
                var html='';
                html+='<div style="position:relative;display:inline-block; float:left;margin-right:10px;">';
                html+=' <em class="ico-close J-ico-close"></em>';
                if(opt['number'] == 'order_video'){
                    html+='<a href="javascript:;" class="J-video-obj" data-url="'+obj['msg']['ai_ftpurl']+''+obj['msg']['ai_path']+'" style="position:relative; display:inline-block; width:80px;height:80px;">';
                }else{
                    html+='<a href="'+obj['msg']['ai_ftpurl']+''+obj['msg']['ai_path']+'" data-lightbox="pic" style="position:relative; display:inline-block; width:80px;height:80px;">';
                }
                switch(opt.number){
                    case 'order_video':
                        html+=' <img class="example-image" src="<?php echo BASE_STYLE;?>/images/member/default_sildeshow.gif" width="80" height="80" />';
                        html+=' <input type="hidden" value="'+obj['msg']['af_path']+'" name="oa_video[]" />';
                        break;
                }
                html+='</a>';
                html+=' <p width="80" height="80">'+owner_name+' </p>';
                html+='</div>';
                $(opt.queueClass).append(html);
                Ext.Msg.alert('提示','上传成功');
            }else{
                Ext.Msg.alert('提示',obj['msg']);
                return false;
            }

            }
      });
    };

    $(document).ready(function(e) {
        $("select#owner").change(function(){
        owner_name = document.getElementById("owner").value;
        render_upload();
        var sitem = document.getElementById("owner");
        sitem.setAttribute('disabled','disabled');
        var vnitem = document.getElementById("video_owner"); 
        vnitem.setAttribute('value',owner_name)
    });
        $("#video_submit").submit(function(e){
        var winElement = parent.Ext.fly(window.frameElement).up('div.x-window');
        parent.Ext.getCmp(winElement.id).close();
    });

        //删除上传的图片
        $(".order-item-box").on('click','.J-ico-close',function(){
            $(this).closest('div').remove();
        });
        $(".J-a-btn-close","").on('click',function(){
        var winElement = parent.Ext.fly(window.frameElement).up('div.x-window');
        parent.Ext.getCmp(winElement.id).close();
        });
        //默认加载
        //getAttachmentList(true);
    });
</script>

<style type="text/css">
    .mianqianxinxi-box {
        height:auto;
        overflow:hidden;
        margin-top:15px;
    }
    
    .mianqianxinxi-box dt {
        margin-bottom:10px;
    }
    .mianqianxinxi-box dd {
        float:left;
    }
    
    .mianqianxinxi-pic-list {
        margin-right:10px;
    }
    
    .mianqianxinxi-pic-list img {
        margin-right:10px;
    }
    
    
</style>
<?php include $this->Render('footer.php'); ?>